<template>
	<view class="box">
		<view v-if="hasLogin">
			<view class="shipei" >
				<u-row  justify="space-between">
					<u-col span="2" >
						<view class=" "  >
							<u-avatar src="https://cdn.uviewui.com/uview/album/1.jpg"></u-avatar>
						</view>
					</u-col>
					<u-col span="3">
						<view class=" " >
							 {{userInfo.name}}
						</view>
					</u-col>
					<u-col span="2">
					<!-- 	<u-icon label="" size="14" :bold="true" name="arrow-right"></u-icon> -->
					</u-col>
					<u-col span="20">
						
					</u-col>
				</u-row>
			</view>
			
			<view class="content">
				<u-row  justify="space-between" > 
					<u-col span="6" >
						<view class="body-layoutleft" >
							<p style="font-size: 13px;">今日累计收入(元)</p>
							<p style="font-size: 21px;">{{(dailyIncome/100).toFixed(2)}}</p>
							<p style="height: 20px;"  @click="navigateTo(account)"></p>
						</view>
						
					</u-col>
					<u-col span="6">
						<view class="body-layoutright" >
							<p style="font-size: 13px;">今日完成单量(单)</p>
							<p style="font-size: 21px;">{{total}}</p>
							<p style="font-size: 10px;font-weight: 400;"  @click="navigateTo(account)">我的账户></p>
							<!-- <p style="font-size: 10px;font-weight: 400;" @click="navigateTo(orderForm)">订单统计></p> -->
						</view>
					</u-col>
				
				</u-row>
			</view>
			<view class="content2">
				<u-cell-group :border='false'>
					<u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png"
						title="服务长者" :isLink="true" arrow-direction="left"@click="navigateTo(elderly)">
					</u-cell>
					<u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png" title="个人资料" :isLink="true" arrow-direction="left"@click="navigateTo(myInformation)"></u-cell>
					<u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png" title="违规罚款" :isLink="true" arrow-direction="left" @click="navigateTo(fine)"></u-cell>
					<!-- <u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png" title="我的评价" :isLink="true" arrow-direction="left"@click="utils.developing"></u-cell> -->
					<u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png" title="修改密码" :isLink="true" arrow-direction="left"@click="navigateTo(passwordUpdate)"></u-cell>
					<!-- <u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png" :title="isNotice==0?'开启通知':'关闭通知'" :isLink="true" arrow-direction="left" @click="noticeTitalClick()"></u-cell> -->
					<u-cell :rightIconStyle="rightIconStyle" :border='false' icon="https://cdn.uviewui.com/uview/example/tag.png" 
					title="测试" :isLink="true" arrow-direction="left"@click="navigateTo(text)"></u-cell>
				</u-cell-group>
			</view>
			<view class="content2">
				<u-button   @click="toLogout" :plain="true" shape="circle" size="small" text="退出登录"></u-button>
			</view>
		</view>
		<!-- 未登录显示 -->
		<view v-else @click="navigateTo(login)" >
			<u-empty  mode="permission"textColor="#f00000"     text="请先登录>"   >
			</u-empty>
		</view>
		
	</view>
</template>
      
<script>
	import {
	    mapState 
	} from 'vuex';
	import {
	    mapMutations  
	} from 'vuex';
	import uRow from "@/pagesB/uview-ui/components/u-row/u-row";
	import uCol from "@/pagesB/uview-ui/components/u-col/u-col";
	import uDivider from "@/pagesB/uview-ui/components/u-steps/u-steps";
	import uSteps from "@/pagesB/uview-ui/components/u-steps/u-steps";
	import uStepsItem from "@/pagesB/uview-ui/components/u-steps-item/u-steps-item";
	import uButton from "@/pagesB/uview-ui/components/u-button/u-button";
	import uPopup from "@/pagesB/uview-ui/components/u-popup/u-popup";
	import uLoadmore from "@/pagesB/uview-ui/components/u-loadmore/u-loadmore";
	import uEmpty from "@/pagesB/uview-ui/components/u-empty/u-empty";
	import uTabs from "@/pagesB/uview-ui/components/u-tabs/u-tabs";
	import uTabbar from "@/pagesB/uview-ui/components/u-tabbar/u-tabbar";
	import uNavbar from "@/pagesB/uview-ui/components/u-navbar/u-navbar";
	import uIcon from "@/pagesB/uview-ui/components/u-icon/u-icon";
	import uBadge from "@/pagesB/uview-ui/components/u-badge/u-badge";
	import uCellGroup from "@/pagesB/uview-ui/components/u-cell-group/u-cell-group";
	import uCell from "@/pagesB/uview-ui/components/u-cell/u-cell";
	import uAvatar from "@/pagesB/uview-ui/components/u-avatar/u-avatar";
	
	export default {
		components:{
			uRow,uCol,uDivider,uSteps,uStepsItem,uButton,uLoadmore,uPopup,uEmpty,uTabs,uTabbar,uNavbar,uIcon,uBadge,uCellGroup,uCell,uAvatar
		}, 
		data() {
			return {
				value6: 0,
				rightIconStyle:{
					color: '#d8d8d8'
				},
				account:"/pagesB/my/account",
				orderForm:"/pagesB/my/orderForm",
				login:"/pages/login/login",
				myInformation:"/pagesB/my/myInformation",
				fine:"/pagesB/my/fine",
				passwordUpdate:"/pagesB/my/passwordUpdate",
				elderly:"/pagesB/elderly/elderly",
				text:"/pagesB/my/text",
				dailyIncome:0,
				total:0,
				pageVO:{
					pageNo: 1,
					pageSize: 99,
					technicianId:"", 
					receiveStatus:4,//技师接单状态（1未接单，2已接单，3服务中，4已完成，5拒绝接单，6取消）
					//datatype:"sun",
					completeTime:"2023-10-09",
					sort:"asc",//排序
				},
				isNotice:0
			}
		},
		computed: {
			//获取是否登录
			...mapState(['hasLogin','userInfo']) 
		},
		mounted() {
			this.pageVO.completeTime=uni.$u.timeFormat(new Date(), 'yyyy-mm-dd')
			this.showPage()
		},
		onShow(){
		},
		methods: {
			...mapMutations(['logout']),
			showNotice(){
				this.request.getRequest(this.http.httpsLian.selNotice,{
					mobile:uni.getStorageSync('mobile')
				}, false).then(res => { 
					if(res.code==0){
						this.isNotice=res.data.isNotice
					}
				}).catch(res => {
					uni.$u.toast(res)
				})
			},
			noticeTitalClick(){
				//得取技师账户
				let noticeTital=this.isNotice;
				if(noticeTital==0){
					//开启接口
					uni.navigateTo({ url: "/pages/code/code" });
					setTimeout(()=>{this.showNotice();},2500)
				}else{
					//调用关闭的接口
					this.request.postRequest(this.http.httpsLian.updateNotice,{
						mobile:uni.getStorageSync('mobile')
					}, false).then(res => { 
						this.showNotice();
					})
				}
			},
			//获取数据
			showPage(){
				this.dailyIncome=0;
				this.pageVO.technicianId=this.userInfo.id
				this.request.getRequest(this.http.httpsLian.orderDispatchRecord,this.pageVO, false)
				.then(res => { 
					if(res.code!=0 )return ;
					res.data.list.forEach(item=>{
						this.dailyIncome+=item.totalPrice
					})
					this.total=res.data.total
				}).catch(res => {
					uni.$u.toast(res)
				})
			},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录么',
				    success: (e)=>{
				    	if(e.confirm){
				    		this.logout();
				    		setTimeout(()=>{
				    			uni.navigateBack();
				    		}, 200)
				    	} 
				    }
				});
				//子组件事件
				//this.$emit('Logout',"SSL")
			},
			navigateTo(urls) {
				uni.navigateTo({
				   url: urls
				});
				//alert(urls)
			}
		}
	}
</script>

<style lang="scss" scoped>
page{
	
}
.box{
	padding: 10px 10px;
	width: 600upx;
	background-color: white;
}
.shipei{
	padding-top:  var(--status-bar-height);
}
.head_name view{
	float: left;
}
.name{
		margin-top: 12px;
		margin-left: 10px;
	}
.name view{
	float: right;
	margin-top: 5px;
	margin-left: 8px;
}
.content{
	background-color: #ffd02b;
	margin-top: 10px;
	padding:10px 0px;
	.body-layoutright,.body-layoutleft{
		text-align: center;
		font-weight: 550;
		p{
			margin-bottom: 6px;
		}
	}
}	
.content2{
	margin-top: 10px;
	padding:10px 0px;
	background-color: white;
	border-radius: 5px;
	/deep/.uni-section-header{
	    padding: 0px ; 
	}
	/deep/.uni-section {
		background-color: #fff;
		margin-top: 0px;
	}
	/deep/.line {
		background-color: #f5c61c;
	}
	/deep/.uni-section__content-title {
		font-size: 13px;
		font-weight: bolder;
		
	}
}
.u-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: $u-border-color;
		padding: 3px 0px;
		
		opacity: 0.8;
		.u-button{
			margin-left: 10px;
		}
		span{
			color: white;
			font-size: 14px;
		}
	}
</style>
